package com.framework.utiles;

import com.framework.dto.FileUrlDTO;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;

/**
 * @Description: 文件路径处理工具类
 * @Author: JamesYao
 * @DateTime: 2024/2/20 22:38
 */
public class FileUrlUtils {
    public static FileUrlDTO getFileUrl(String fileUrl) {
        URL url = null;
        try {
            url = new URL(fileUrl);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        }
        String path1 = url.getPath();
        String substring = path1.substring(1, path1.length());
        String[] split = substring.split("/");
        String bucketName = split[0];
        String fileName = split[1];
        return new FileUrlDTO(bucketName, fileName);
    }

}
